﻿$(function(){//延迟加载  
	var dvmodelId=$('#dvmodelId').val();
	var jfId=$('#jfId').val();
	var swId=$('#swId').val();
	var swname=$('#swname').val();
	var swip=$('#swip').val();
	$('#xhrow').load('dvfirmsec?dvmodelId='+dvmodelId,function(){
		$.getScript('/xasj/js/component/dvmodelsec.js');
	});
	
	$('#jfrow').load('showjifangsec?jfId='+jfId,function(){
		$.getScript('/xasj/js/component/jifangsec.js');
		$('#jifang').combobox({
			width:'100%'
		});
	});
	
	$('#compledit').linkbutton({
		onClick:function(){
			jfId=$('#jifang').combobox('getValue');
			dvmodelId=$('#dvmodel').combobox('getValue');
			var ipbegin=$('#ipbegin').val();
			var ipend=$('#ipend').val();
			swip=$('#swip').val();
			var swgw=$('#swgw').val();
			swname=$('#swname').val();
			$.ajax({
				url:'compleditsw',
				type:'POST',
				data:{
					swId:swId,
					ipbegin:ipbegin,
					ipend:ipend,
					swip:swip,
					swgw:swgw,
					jfId:jfId,
					swname:swname,
					dvmodelId:dvmodelId
				},
				success:function(data){
					alert(data.msg);
				}
			});
//			alert('ok');
		}
	});
	$('#dvtp').linkbutton({
		onClick:function(){
			parent.addTab(swname+'('+swip+')','tojxtp?dvIds=switch'+','+swId+'&sectype=1','zzjg');
		}
	});
	$('#deleteolt').linkbutton({
		onClick:function(){
			$.ajax({
				url:'deletedv',
				type:'POST',
				data:{
					dvbelong:'olt',
					dvipbelong:'oltip',
					dvId:oltId
				},
				success:function(data){
					if(data.msg=='1'){
						alert('删除成功！');
						parent.removeTab($('#oltname').val());					
					}else{
						alert(data.msg);
					}
				},
				error:function(){
					alert('删除失败');
				}
			});
		}
	});
	
    $.extend($.fn.validatebox.defaults.rules, {    
    	 ip : {// 验证IP地址  
             validator : function(value) {  
                 var reg = /^((1?\d?\d|(2([0-4]\d|5[0-5])))\.){3}(1?\d?\d|(2([0-4]\d|5[0-5])))$/ ;  
                 return reg.test(value);  
             	},  
             message : 'IP地址格式不正确'  
    	 	}
    });
});